<script language="javascript">
$(document).ready(function() {
   
    $("#namhoc").change(function(){
        
        var namhoc = $("#namhoc option:selected").text();
        var url=window.location.pathname;
        var num=url.lastIndexOf('/')+1;
        var chidoanid=url.substring(num);
        var namhocht="<?php echo $phanloaicbs[0]['Z1plcb']['namhoc'];?>";
        //if(!=hockyht){
            if(namhocht!=namhoc){ 
                $('#thongke').load( 
                       "../thongke/" + namhoc + "/"+chidoanid
                       , function () {                         
                        $(this).show();
                        $("#duyetpl").hide();
                       }); 
                   
            }else{
                $('#thongke').hide();
                $("#duyetpl").show();   
            }
    })            
            
        //}
        

        
    
});
</script>
<script>
$(function() {
	$( "#tabs" ).tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    },
	selected: 1 
	});
});
</script>
<div id="tabs">
	<ul>
        <li><?php echo $this->Html->link(__('Danh sách chi đoàn', true), array('controller'=>'chidoansvs','action' => 'duyetcd',$user['Z1user'] ['khoa_id'])); ?></li>
        <li><a href='#duyetcd'>Kết quả PLĐV & ĐVUT</a> </li>
    </ul>
<div class="phanloaicbs index" id="#duyetcd">
<h2 align="center"><?php __('Chi đoàn: '.$chidoan['Chidoansv']['tenchidoan'].' ('.$chidoan['Chidoansv']['machidoansv'].')');?></h2>
<?php       
      $index = array_search($phanloaicbs[0]['Z1plcb']['namhoc'],$namhocs);
      echo $this->Form->input('namhoc',array('type'=>'select','label'=>'Năm học','options'=>$namhocs,'default'=>$index,'id'=>'namhoc'));
?>

<div id="thongke"></div>
<div id="duyetpl">
<?php if(!empty($phanloaicbs)):?>
<br />     
    <h3><?php __('Kết quả phân loại đoàn viên năm học '.$phanloaicbs[0]['Z1plcb']['namhoc']);?></h3>
    <?php 
        if(count($phanloaicbs)>0){
            echo '<table width=25% border="1" cellpadding="0" cellspacing="0" >';
            echo '<tr>';
            echo '<td style="padding: 5px 5px 5px ;">';
            echo "Xuất sắc: ".$tlxs.'%';
            echo '</td>';
            echo '<td style="padding: 5px 5px 5px ;">';
            echo "Khá: ".$tlk.'%';
            echo '</td>';
            echo '</tr>';
            echo '<tr>';
            echo '<td style="padding: 5px 5px 5px ;">';
            echo "Trung bình: ".$tltb.'%';
            echo '</td>';
            echo '<td style="padding: 5px 5px 5px ;">';
            echo "Yếu: ".$tly.'%';
            echo '</td>';
            echo '</tr>';
            echo '</table>';
            echo '<br/';
            //echo $this->Form->create('Loaicdcb',array('action'=>'phanloaicd'));
//            echo $this->Form->input('xeploaicd_id',array('type'=>'select','label'=>'Xếp loại chi đoàn','options'=>$loaicdsv,'default'=>$loaicd));
//            echo $this->Form->end('Phân loại CĐ');
            foreach($loaicdsv as $xeploaicd){
             if($loaicd==$xeploaicd['Xeploaicd']['id']) echo "<div><b>Xếp loại chi đoàn: ".$xeploaicd['Xeploaicd']['loaicd']."</b></div><br/>";   
            }
        }else {
            echo "Chưa phân loại cán bộ!";
        }
        
    ?>
    <?php echo $form->create('Phanloaicb',array('action'=>'duyet'));?>
    <?php echo $this->Form->input('chidoan_id', array('type'=>'hidden','value'=>$chidoan['Chidoansv']['id']));?>
	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
            <th><?php __('STT');?></th>
            <th><?php 
                    echo $this->Form->checkbox('all',array('id'=>'checkallduyet')) ;
                    __('Đã duyệt');
            ?></th>
            <th><?php 
                    echo $this->Form->checkbox('all',array('id'=>'checkallchuaduyet')) ;
                    __('Chưa duyệt');
            ?></th>
			<th><?php __('Xếp loại');?></th>
			<th><?php __('MSCB');?></th>
            <th><?php __('Họ Tên');?></th>
			<th><?php __('Danh Hiệu');?></th>
			<th><?php __('Tên Phong Trào');?></th>
            <th><?php __('Ghi Chú');?></th>
	</tr>
	<?php
	$i = 0;
    $j=0;
	foreach ($phanloaicbs as $phanloaicb):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
        <td><?php echo $i;?></td>
        <td><?php if($phanloaicb['Z1plcb']['duyet']==0) echo $this->Form->checkbox('Phanloaicb.duyet.'.$phanloaicb['Z1plcb']['canbo_id'],array('class'=>'duyet')); else echo "Đã duyệt";?></td>
        <td><?php if($phanloaicb['Z1plcb']['duyet']==1) echo $this->Form->checkbox('Phanloaicb.chuaduyet.'.$phanloaicb['Z1plcb']['canbo_id'],array('class'=>'chuaduyet')); else echo "Chưa duyệt";?></td>
		<td>
            <?php 
                foreach($xeploais as $xeploai)
                if($xeploai['Xeploai']['id']==$phanloaicb['Z1plcb']['xeploai_id'])echo $xeploai['Xeploai']['tenloai']; 
            ?>
			<?php //echo $form->input('xeploai_id'.$j,array('type'=>'select','label'=>'','options'=>$xeploais,'default'=>$phanloaicb['Z1plcb']['xeploai_id'])); ?>
		</td>
		<td>
			<?php echo $phanloaicb['Z1plcb']['mscb']; ?>
		</td>
        <td><?php echo $phanloaicb['Z1plcb']['hoten']?></td>
		<td><?php echo $phanloaicb['Z1plcb']['danhhieu']; ?>&nbsp;</td>
		<td><?php echo $phanloaicb['Z1plcb']['tenphongtrao']; ?>&nbsp;</td>
        <td><?php echo $phanloaicb['Z1plcb']['ghichu']; ?>&nbsp;</td>
	</tr>
    <?php $j++;?>
<?php endforeach; ?>
	</table>
    <?php
     echo $this->Form->end('Lưu');
?>
<?php else:?>
    <?php echo "Không có dữ liệu!";?>
<?php endif;?>     

<div class="dvutcbs index">
<?php if(!empty($dvutcbs)):?>        
	<h2><?php __('Kết quả bình xét đoàn viên ưu tú năm học '.$dvutcbs[0]['Z1dvutcb']['namhoc']);?></h2>

    <?php echo $this->Form->create('Dvutcb',array('action'=>'duyet'));?>
    <?php echo $this->Form->input('chidoan_id',array('type'=>'hidden','value'=>$chidoan['Chidoansv']['id']));?>
	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
            <th><?php __('STT');?></th>
            <th>
                <?php 
                echo $this->Form->checkbox('all',array('id'=>'checkallduyet')) ;
                __('Đã Duyệt');
                ?>
            </th>
            <th>
                <?php 
                echo $this->Form->checkbox('all',array('id'=>'checkallchuaduyet')) ;
                __('Chưa duyệt');
                ?>
            </th>
			<th><?php __('MScb');?></th>
            <th><?php __('Họ tên');?></th>
			<th><?php __('Số người đồng ý');?></th>
			<th><?php __('Ghi chú');?></th>            
            <th><?php __('Action');?></th>
	</tr>
	<?php
	$i = 0;
    $j=1;
	foreach ($dvutcbs as $dvutcb):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
        <td>
            <?php echo $i;?>
        </td>
        <td><?php if($dvutcb['Z1dvutcb']['duyet']==0) echo $this->Form->checkbox('Dvutcb.duyet.'.$dvutcb['Z1dvutcb']['id'],array('class'=>'duyet')); else echo "Đã duyệt";?></td>
        <td><?php if($dvutcb['Z1dvutcb']['duyet']==1) echo $this->Form->checkbox('Dvutcb.chuaduyet.'.$dvutcb['Z1dvutcb']['id'],array('class'=>'chuaduyet')); else echo "Chưa duyệt";?></td>
        <td>
            <?php echo $dvutcb['Z1dvutcb']['mscb'];?>
        </td>
        <td>
            <?php echo $dvutcb['Z1dvutcb']['hoten'];?>
        </td>
		<td><?php echo $dvutcb['Z1dvutcb']['songuoidongy'].'/'.$dvutcb['Z1dvutcb']['songuoithamgiabau'];?>&nbsp;</td>
        <td>
            <?php echo $dvutcb['Z1dvutcb']['ghichu'];?>
        </td>
        <td class="actions">        
            <?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $dvutcb['Z1dvutcb']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $dvutcb['Z1dvutcb']['mscb'])); ?>
		</td>		
	</tr>
    <?php $j++;?>
<?php endforeach; ?>
	</table>
     <?php
     echo $this->Form->end('Lưu');
    ?>
<?php else:?>
    <?php echo "Chưa bình xét đoàn viên ưu tú!";?>
<?php endif;?>       
</div>
</div>
</div>
</div>